import Cookies from 'js-cookie'
let ZXCO = 'zx_collect'
let ZXWEBAPP2004 = "zx_coutdonw"
let TOKEN='token';

export const setZXCO = (id, isDelete) => {
    let arr = getZXCO()
    if (isDelete) {
        let arrs = arr.filter(res => {
            return res != id
        })
        localStorage.setItem(ZXCO, JSON.stringify(arrs))
    } else {
        // 判断数组内是否包含当前id
        if (arr.includes(id)) {
            return
        } else {
            console.log(id)
            arr.push(id)
            localStorage.setItem(ZXCO, JSON.stringify(arr))
        }
    }
}
export const getZXCO = () => {
    return JSON.parse(localStorage.getItem(ZXCO)) || []
}
export const delZXCO = nm => {
    let arr = getZXCO()
    arr.splice(nm,1)
    localStorage.setItem(ZXCO, JSON.stringify(arr))
}
///////////////////////////////////////////

export const addStorage = (n,bool )=> {
    let getstr = getStorage()
    if(bool){
        console.log(n)
        getstr=n
        localStorage.setItem(ZXWEBAPP2004, JSON.stringify(getstr))
        return
    }
    if (getstr.includes(n)) {
        return;
    } else {
        getstr.push(n)
        localStorage.setItem(ZXWEBAPP2004, JSON.stringify(getstr))
    }

}
export const getStorage = n => {
    return JSON.parse(localStorage.getItem(ZXWEBAPP2004) || "[]");
}
///////////////////////////////
const STICK = 'stick'
export const setStick = id => {
  let arr = getStick()
  arr.push(id)
  localStorage.setItem(STICK, JSON.stringify(arr))
}
export const getStick = () => JSON.parse(localStorage.getItem(STICK)) || []
export const delStick = nm => {
  let arr = getStick()
  arr.splice(nm,1)
  localStorage.setItem(STICK, JSON.stringify(arr))
}




